import 'package:flutter/material.dart';

/**
 * image控件
 */
class ImageWidget extends StatelessWidget {
  const ImageWidget({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('image组件'),
        centerTitle: false,
        backgroundColor: Colors.blue,
      ),
      body: Column(
        children: [
          ///本地图片------------------------------
          Image.asset(
            'images/s227.png',
            height: 120,
            width: 220,

            //重复图片  形式展示图片
            // repeat: ImageRepeat.repeat,

            // 单个图片占满全屏，图片比例可能发生改变
            // fit: BoxFit.fill,
            //切割的形式展示图片
            fit: BoxFit.cover,
          ),

          ///网络图片-----------------------------
          Image.network(
            'https://pics0.baidu.com/feed/a2cc7cd98d1001e922dcad5a2cd03bea56e797e3.jpeg@f_auto?token=598a9ecf446969343f6810396b04339a&s=FCC27A2B4A1227FF6615E11E0100E091',
            width: 220,
            height: 300,
          ),

          ///圆形图片--------------------------------
          const CircleAvatar(
            //本地圆形
            // backgroundImage: AssetImage('images/s227.png'),
            //网络图片
            backgroundImage: NetworkImage(
                'https://pics0.baidu.com/feed/a2cc7cd98d1001e922dcad5a2cd03bea56e797e3.jpeg@f_auto?token=598a9ecf446969343f6810396b04339a&s=FCC27A2B4A1227FF6615E11E0100E091'),

            radius: 50,
          ),

          //占位图图片，
          const FadeInImage(
            width: 200,
            height: 200,
            //网络不好用本地图片
            placeholder: AssetImage('images/s227.png'),
            image: NetworkImage(
              'https://pics0.baidu.com/feed/a2cc7cd98d1001e922dcad5a2cd03bea56e797e3.jpeg@f_auto?token=598a9ecf446969343f6810396b04339a&s=FCC27A2B4A1227FF6615E11E0100E091',
            ),
          ),

        ],
      ),
    );
  }
}
